﻿<UserControl x:Class="Tum.PDE.ToolFramework.Modeling.Visualization.Controls.Loaders.ImageLoaderControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="120" d:DesignWidth="120">
    <UserControl.Resources>
        <Storyboard x:Key="LoadingImgStoryboard">
            <DoubleAnimation From="0" To="359" Duration="00:00:01" RepeatBehavior="Forever"
                           Storyboard.TargetName="loadingImage" 
                           Storyboard.TargetProperty="(Image.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)">
            </DoubleAnimation>
        </Storyboard>
    </UserControl.Resources>

    <UserControl.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource LoadingImgStoryboard}"/>
        </EventTrigger>
    </UserControl.Triggers>
    <Grid>
        <TextBlock Text="Loading..." HorizontalAlignment="Center" VerticalAlignment="Center"/>
        <Image x:Name="loadingImage">
            <Image.Source>
                <DrawingImage>
                    <DrawingImage.Drawing>
                        <DrawingGroup>
                            <GeometryDrawing Brush="Transparent">
                                <GeometryDrawing.Geometry>
                                    <RectangleGeometry Rect="0,0,1,1"/>
                                </GeometryDrawing.Geometry>
                            </GeometryDrawing>

                            <DrawingGroup>
                                <DrawingGroup.Transform>
                                    <RotateTransform  Angle="0" CenterX="0.5" CenterY="0.5"/>
                                </DrawingGroup.Transform>
                                <GeometryDrawing>
                                    <GeometryDrawing.Pen>
                                        <Pen Brush="Gray" Thickness="0.1"/>
                                    </GeometryDrawing.Pen>
                                    <GeometryDrawing.Geometry>
                                        <PathGeometry>
                                            <PathFigure StartPoint="0.9,0.5">
                                                <ArcSegment Point="0.5,0.1" RotationAngle="90" SweepDirection="Clockwise" IsLargeArc="True" Size="0.4,0.4"/>
                                            </PathFigure>
                                        </PathGeometry>
                                    </GeometryDrawing.Geometry>
                                </GeometryDrawing>
                                <GeometryDrawing Brush="Gray">
                                    <GeometryDrawing.Geometry>
                                        <PathGeometry>
                                            <PathFigure StartPoint="0.5,0">
                                                <LineSegment Point="0.7,0.1" />
                                                <LineSegment Point="0.5,0.2" />
                                            </PathFigure>
                                        </PathGeometry>
                                    </GeometryDrawing.Geometry>
                                </GeometryDrawing>
                            </DrawingGroup>

                        </DrawingGroup>
                    </DrawingImage.Drawing>

                </DrawingImage>
            </Image.Source>
            <Image.RenderTransform>
                <TransformGroup>
                    <RotateTransform Angle="1"/>
                    <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                    <SkewTransform AngleX="0" AngleY="0"/>
                    <TranslateTransform X="0" Y="0"/>
                </TransformGroup>
            </Image.RenderTransform>
            <Image.RenderTransformOrigin>
                <Point X="0.5" Y="0.5"/>
            </Image.RenderTransformOrigin>
        </Image>
            
    </Grid>
</UserControl>
